
{extends file="../acp.html"}
{block name="css"}
<link rel="stylesheet" href="/Public/Css/acp/AcpOrder/order_detail.css" type="text/css" />

<style type="text/css">
    .delete_icon{
        background-color: #fff;
        border-radius: 50%;
        background-image: url(/Public/Images/front/front_img/dele.png);
        background-size: 25px 25px;
        width: 25px;
        height: 25px;
        display: inline-block;
        position: absolute;
        top:-10px;
        right: -10px;
    }
    .img_class{
        width:100px;
        float:left;
        position:relative;
        margin-right:15px
    }
</style>
{/block}
{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-detail-goods">
    <div class="t-detail-goods-tit mag">帖子信息：</div>
    <div class="t-detail-goods-con t-buser">
    	<table class="wxtables tables-form">  
            <colgroup>  
                <col width="10%">  
                <col width="90%">   
            </colgroup>  
            <tbody>
                 <tr>
                     <!--wangtao 2017.9.19 -strat-->
                     <td class="tables-form-title">帖子名称：</td>
                     <td>{if $post_info.title}
                         <input  class="content title"name="title" disabled value="{$post_info.title}" />
                         <span class="btn btn-red edit">修改</span>
                         <div class="operate" style="display: none">
                             <span class="btn btn-blue cancel">取消</span>  <span class="btn btn-blue save" data-post_id="{$post_info.post_id}" data-content_type="title">保存</span>
                         </div>
                         {else}--{/if}
                     </td>
                     <!--wangtao 2017.9.19 -end-->

                 </tr>
                <tr>
                    <td class="tables-form-title">所属频道：</td>
					<td>{if $post_info.channel_name}{$post_info.channel_name}{else}--{/if}</td>
                </tr>
                <tr>
                    <td class="tables-form-title">发布人：</td>
					<td>{if $post_info.nick_name}{$post_info.nick_name}{else}--{/if}</td>
                </tr>
                <tr>
                    <td class="tables-form-title">活跃度：</td>
					<td>浏览量：{if $post_info.clickdot}{$post_info.clickdot}{else}--{/if}，点赞量：{if $post_info.praise_num}{$post_info.praise_num}{else}--{/if}，收藏量：{if $post_info.collect_num}{$post_info.collect_num}{else}--{/if}，评论量：{if $post_info.comment_num}{$post_info.comment_num}{else}--{/if}。</td>
                </tr>
                 <tr>
                     <td class="tables-form-title">内容：</td>
                     <td>{if $post_info.content}
                         <textarea class="content" style="width: 90%" disabled name="content">{$post_info.content}</textarea><br/>
                         <span class="btn btn-red edit">修改</span>
                         <div class="operate" style="display: none">
                             <span class="btn btn-blue cancel">取消</span>  <span class="btn btn-blue save" data-post_id="{$post_info.post_id}" data-content_type="normal">保存</span>
                         </div>
                         {else}--{/if}
                     </td>
                 </tr>
                <tr>  
                    <td class="tables-form-title">图片：</td>
                    <td>{if $post_info.imgs}{foreach from = $post_info.imgs item = img}
                    <div class="img_class">
                    <img src="{$img.img_url}?imageMogr2/auto-orient/imageslim" style="width:100px;">
                    <span class="delete_icon" data-img_id="{$img.post_img_id}" data-img_type="normal"></span>
                    </div>
                    {/foreach}{else}--{/if}</td>
                </tr>
            </tbody>  
        </table>   
    </div>
    {if $post_info.post_type ==  PostModel::PRAISE}
	<div class="t-detail-goods-tit mag">赞赏信息：</div>
    <div class="t-detail-goods-con t-buser">
    	<table class="wxtables tables-form">
            <colgroup>
                <col width="10%">
                <col width="90%">
            </colgroup>
            <tbody>
                <tr>
                    <td class="tables-form-title">赞赏价：</td>
					<td>{if $post_info.praise_price}{$post_info.praise_price}元{else}--{/if}</td>
                </tr>
                <tr>
					<td class="tables-form-title">鉴定平均分：</td>
					<td>{if $post_info.avg_score}{$post_info.avg_score}分{else}--{/if}</td>
                </tr>
                 <tr>
                    <td class="tables-form-title">购买人数：</td>
					<td>{$post_info.buy_num|default:0}人</td>
                </tr>
                <tr>
                    <td class="tables-form-title">隐藏文字：</td>
                    <td>
                        {if $post_info.hide_content}
                        <textarea class="content" style="width: 90%" disabled name="content">{$post_info.hide_content}</textarea><br/>
                        <span class="btn btn-red edit">修改</span>
                        <div class="operate" style="display: none">
                            <span class="btn btn-blue cancel">取消</span>  <span class="btn btn-blue save" data-post_id="{$post_info.praise_hide_id}" data-content_type="praise">保存</span>
                        </div>
                        {else}--{/if}
                    </td>
                </tr>
                <tr>
                    <td class="tables-form-title">隐藏图片：</td>
                    <td>{if $post_info.hide_imgs}{foreach from = $post_info.hide_imgs item = img}
                    <div class="img_class">
                    <img src="{$img.img_url}?imageMogr2/auto-orient/imageslim" style="width:100px;">
                    <span class="delete_icon" data-img_id="{$img.praise_hide_img_id}" data-img_type="praise"></span>
                    </div>
                    {/foreach}{else}--{/if}</td>
                </tr>
            </tbody>
        </table>
    </div>
    {/if}
    {if $post_info.post_type ==  PostModel::CROWDFUNDING}
    <div class="t-detail-goods-tit mag">心愿信息：</div>
    <div class="t-detail-goods-con t-buser">
        <table class="wxtables tables-form">
            <colgroup>
                <col width="10%">
                <col width="90%">
            </colgroup>
            <tbody>
            <tr>
                <td class="tables-form-title">心愿状态：</td>
                <td>{$post_info.state}</td>
            </tr>
            <tr>
                <td class="tables-form-title">目标金额：</td>
                <td>{if $post_info.cf_info.goal_money}{$post_info.cf_info.goal_money}元{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">已筹金额：</td>
                <td>{if $post_info.cf_info.now_money}{$post_info.cf_info.now_money}分{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">支持次数：</td>
                <td>{$post_info.cf_info.support_num|default:0}次</td>
            </tr>
            <tr>
                <td class="tables-form-title">心愿时间：</td>
                <td>添加时间:{if $post_info.cf_info.addtime}{$post_info.cf_info.acp_time}{else}{/if}<br/>
                    审核时间:{if $post_info.cf_info.pass_time}{$post_info.cf_info.acp_pass_time}{else}{/if}<br/>
                    结束时间:{if $post_info.cf_info.end_time}{$post_info.cf_info.acp_end_time}{else}{/if}
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="t-detail-goods-tit mag">楼主回帖信息：</div>
    <div class="t-detail-goods-con t-buser">
        <table class="wxtables tables-form">
            <colgroup>
                <col width="10%">
                <col width="90%">
            </colgroup>
            <tbody>
            <tr>
                <td class="tables-form-title">标题：</td>
                <td>{if $post_info.reply_info.title}{$post_info.reply_info.title}{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">内容：</td>
                <td>{if $post_info.reply_info.content}
                    <textarea class="content" style="width: 90%" disabled name="content">{$post_info.reply_info.content}</textarea><br/>
                    <span class="btn btn-red edit">修改</span>
                    <div class="operate" style="display: none">
                        <span class="btn btn-blue cancel">取消</span>  <span class="btn btn-blue save" data-post_id="{$post_info.reply_info.cf_reply_id}" data-content_type="cf_reply">保存</span>
                    </div>
                    {else}--{/if}
                </td>
            </tr>
            <tr>
                <td class="tables-form-title">时间：</td>
                <td>{if $post_info.reply_info.addtime}{$post_info.reply_info.reply_time}{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">图片：</td>
                <td>{if $post_info.reply_img_list}{foreach from = $post_info.reply_img_list item = img}
                    <div class="img_class">
                        <img src="{$img.img_url}?imageMogr2/auto-orient/imageslim" style="width:100px;">
                        <span class="delete_icon" data-img_id="{$img.cf_reply_img_id}" data-img_type="cf_reply"></span>
                    </div>
                    {/foreach}{else}--{/if}</td>
            </tr>
            </tbody>
        </table>
    </div>
    {/if}
    {if $post_info.post_type ==  PostModel::REWARD}
    <div class="t-detail-goods-tit mag">悬赏信息：</div>
    <div class="t-detail-goods-con t-buser">
        <table class="wxtables tables-form">
            <colgroup>
                <col width="10%">
                <col width="90%">
            </colgroup>
            <tbody>
            <tr>
                <td class="tables-form-title">悬赏状态：</td>
                <td>{$post_info.state}</td>
            </tr>
            <tr>
                <td class="tables-form-title">悬赏金额：</td>
                <td>{if $post_info.reward_info.reward_money}{$post_info.reward_info.reward_money}元{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">邀请的用户：</td>
                <td>{if $post_info.reward_info.invite_users}
                    {foreach from = $post_info.invite_name item = invite_name}
                    {$invite_name}
                    {/foreach}
                    {else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">悬赏时间：</td>
                <td>添加时间:{if $post_info.reward_info.addtime}{$post_info.reward_info.acp_time}{else}{/if}<br/>
                    结束时间:{if $post_info.reward_info.end_time}{$post_info.reward_info.acp_end_time}{else}{/if}
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="t-detail-goods-tit mag">采纳答案信息：</div>
    <div class="t-detail-goods-con t-buser">
        <table class="wxtables tables-form">
            <colgroup>
                <col width="10%">
                <col width="90%">
            </colgroup>
            <tbody>
            <tr>
                <td class="tables-form-title">用户昵称：</td>
                <td>{if $post_info.adopted_name}{$post_info.adopted_name}{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">内容：</td>
                <td>
                    {if $post_info.adopted_answer.content}
                    <textarea class="content" style="width: 90%" disabled name="content">{$post_info.adopted_answer.content}</textarea><br/>
                    <span class="btn btn-red edit">修改</span>
                    <div class="operate" style="display: none">
                        <span class="btn btn-blue cancel">取消</span>  <span class="btn btn-blue save" data-post_id="{$post_info.adopted_answer.reward_answer_id}" data-content_type="answer">保存</span>
                    </div>
                    {else}--{/if}

                </td>
            </tr>
            <tr>
                <td class="tables-form-title">时间：</td>
                <td>{if $post_info.adopted_answer.addtime}{$post_info.adopted_answer.adopted_time}{else}--{/if}</td>
            </tr>
            <tr>
                <td class="tables-form-title">图片：</td>
                <td>{if $post_info.answer_img_list}{foreach from = $post_info.answer_img_list item = img}
                    <div class="img_class">
                        <img src="{$img.img_url}" style="width:100px;">
                        <span class="delete_icon" data-img_id="{$img.reward_answer_img_id}" data-img_type="answer_img"></span>
                    </div>
                    {/foreach}{else}--{/if}</td>
            </tr>
            </tbody>
        </table>
    </div>
    {/if}
</div>
{/block}

{block name="js"}
<script src="/Public/Plugins/layer/layer.js"></script>
{literal}
<script>
    $('.container').on('click','.delete_icon',function () {
        var img_id = $(this).attr('data-img_id');
        var img_type = $(this).attr('data-img_type');
        console.log('img_id:'+img_id);
        console.log('img_type:'+img_type);

        layer.confirm('是否删除该图片？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                type:'post',
                url:'/AcpPost/del_img',
                data:{img_id:img_id,img_type:img_type},
                success:function (data) {
                    if(data.code == 1){
                        layer.msg(data.msg, {
                            icon:6,
                            time: 1000, //1s后自动关闭
                            end:function () {
                                location.reload();
                            }
                        });
                    }else{
                        layer.msg(data.msg,{icon:5});
                    }
                }
            })
        });
    })
    var content = '';
    $('.edit').on('click',function () {
        var _this = $(this);
        content = _this.siblings('.content').val();
        _this.hide();
        _this.siblings('.content').attr('disabled',false);
        _this.siblings('.operate').show();
    })

    $('.cancel').on('click',function () {
        var _this = $(this);
        _this.parent().siblings('.content').val(content);
        _this.parent().hide();
        _this.parent().siblings('.content').attr('disabled',true);
        _this.parent().siblings('.edit').show();
    })

    $('.save').on('click',function () {
        var post_id = $(this).attr('data-post_id');
        var content_type = $(this).attr('data-content_type');
        var content = $(this).parent().siblings('.content').val();
        console.log(post_id);
        console.log(content);
        $.ajax({
            type:'post',
            url:'/AcpPost/edit_post_content',
            data:{post_id:post_id,content:content,content_type:content_type},
            success:function (data) {
                if(data.code == 1){
                    layer.msg(data.msg, {
                        icon:6,
                        time: 1000, //1s后自动关闭
                        end:function () {
                            location.reload();
                        }
                    });
                }else{
                    layer.msg(data.msg,{icon:5});
                }
            }
        })
    })




</script>
{/literal}
{/block}